package service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import entity.LayRequest;
import entity.Permission;
import mapper.PermMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermServiceImpl implements PermService{
    @Autowired
    private PermMapper permMapper;
    @Override
    public PageInfo<Permission> selectByPage(LayRequest layRequest) {
        //1.设置当前页和每页记录数
        PageHelper.startPage(layRequest.getPage(),layRequest.getLimit());
        //2. 执行查询
        List<Permission> permissionList=permMapper.selectByMap(layRequest.getParams());
        //3.创建PageInfo对象
        return new PageInfo<>(permissionList);
    }

    @Override
    public boolean insert(Permission permission) {
        return permMapper.insert(permission)>0?true:false;
    }
}
